package fst.parsing

import fst.results.Results

trait Inputters extends Results {
  // The type of the elements consumed by this parser
  type Elem
  type Input
  implicit def InputIsParseInput(in: Input): ParseInput //T 
  
  type Info = Input
  def chooseBestResult(a: NoSuccess, b: NoSuccess): NoSuccess = if(a.info.laterThan(b.info)) a else b
  
  trait ParseInput {
    val self: Input
    
  	def first: Elem
    def rest: Input

//    def pos: Position
    def laterThan(o: Input): Boolean
    def atEnd: Boolean

  	def result[T](r: T): Success[T] = Inputters.this.result(self, r)
    def failure: Failure  = Inputters.this.failure(self)
    def error: Error = Inputters.this.error(self)
  }
}